package com.orhon.smartcampus.modules.systemctl.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;

import com.orhon.smartcampus.modules.user.entity.Users;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
@EqualsAndHashCode
@Entity
@Table(name = "systemctl_operation_user_relation", schema = "smartcloud", catalog = "")
public class OperationUserRelation {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;
    @Column(name = "created_at", nullable = false)
    private Date createdAt;
    @Column(name = "deleted_at", nullable = false)
    private Date deletedAt;

    @ManyToOne
    @Where(clause = "ISNULL(deleted_at)")
    @JoinColumn(name = "operation_id", referencedColumnName = "id")
    @NotFound(action=NotFoundAction.IGNORE)
    private Operations systemctlOperationsByOperationId;

    @ManyToOne
    @Where(clause = "ISNULL(deleted_at)")
    @JoinColumn(name = "user_id", referencedColumnName = "id")
    @NotFound(action=NotFoundAction.IGNORE)
    private Users userUsersByUserId;

}
